package com.xiaohai.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.context.annotation.Configuration;

import java.time.LocalDateTime;

/**
 * ClassName:MyMetaObjectHandler
 * Package:IntelliJ IDEA
 * Description:mybatis plus的自动填充配置
 * Author 何诗海
 *
 * @Create 2024/1/22 15:56
 * @Version 1.0
 */
@Slf4j
@Configuration
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        log.info("开始新增填充....");
        metaObject.setValue("createTime", LocalDateTime.now());
        metaObject.setValue("updateTime", LocalDateTime.now());
        metaObject.setValue("isDelete",0);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        log.info("开始更新填充....");
        metaObject.setValue("updateTime", LocalDateTime.now());
    }
}
